<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>从指定的参数创建新类实例</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reflectionclass.isuserdefined.html">« ReflectionClass::isUserDefined</a></li>
      <li style="float: right;"><a href="reflectionclass.newinstanceargs.html">ReflectionClass::newInstanceArgs »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.reflectionclass.html">ReflectionClass</a></li>
    <li>从指定的参数创建新类实例</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="reflectionclass.newinstance" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionClass::newInstance</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionClass::newInstance</span> &mdash; <span class="dc-title">从指定的参数创建新类实例</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionclass.newinstance-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionClass::newInstance</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">...$args</code></span>): <span class="type">object</span></div>

  <p class="para rdfs-comment">
   创建类的新的实例。给出的参数将会传递到类的构造函数。
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionclass.newinstance-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">args</code></dt>

     <dd>

      <p class="para">
       接受可变数目的参数，用于传递到类的构造函数，和 <span class="function"><a href="function.call-user-func.html" class="function">call_user_func()</a></span> 很相似。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionclass.newinstance-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">

  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-reflectionclass.newinstance-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   如果类的构造函数不是 public 的将会导致一个 <span class="classname"><a href="class.reflectionexception.html" class="classname">ReflectionException</a></span>。
  </p>
  <p class="para">
   当 <code class="parameter">args</code> 指定了一个或多个参数，而类不具有构造函数时,将导致一个 <span class="classname"><a href="class.reflectionexception.html" class="classname">ReflectionException</a></span>。
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionclass.newinstance-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="reflectionclass.newinstanceargs.html" class="methodname" rel="rdfs-seeAlso">ReflectionClass::newInstanceArgs()</a> - 从给出的参数创建一个新的类实例</span></li>
    <li class="member"><span class="methodname"><a href="reflectionclass.newinstancewithoutconstructor.html" class="methodname" rel="rdfs-seeAlso">ReflectionClass::newInstanceWithoutConstructor()</a> - 创建新的类实例而不调用它的构造函数</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>